import java.util.Scanner;

class NameException extends RuntimeException{
    private String message;

    public NameException(String message) {
        super(message);
        this.message = message;
    }

    @Override
    public String getMessage() {
        return message;
    }
}

class PasswordException extends RuntimeException{
    private String message;

    public PasswordException(String message) {
        super(message);
        this.message = message;
    }

    @Override
    public String getMessage() {
        return message;
    }
}

public class Login{
    private String name = "root";
    private String password = "root";

    public void test(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入账号：");
        String name = sc.nextLine();
        System.out.println("请输入密码：");
        String password = sc.nextLine();
        if(!name.equals(this.name)){
            throw new NameException("账号错误");
        }
        if(!password.equals(this.password)){
            throw new PasswordException("密码错误");
        }
    }

    public static void main(String[] args) {
        Login login = new Login();
        try{
            login.test();
        } catch (NameException e){
            System.out.println(e.getMessage());
        } catch (PasswordException e){
            System.out.println(e.getMessage());
        }

    }
}
